<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta charset="UTF-8">
	<title>门票订单列表</title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />


<!-- 新模板 -->
<link rel="shortcut icon" href="<c:url value='/template/new_muban/images/favicon.ico'/>" type="image/x-icon"/>

<!-- 最新导入 -->
<script type="text/javascript" src="<c:url value='/template/new_muban/js/jquery-min-1.7.js'/>"></script>
<link rel="stylesheet" href="<c:url value='/template/new_muban/css/font.css'/>">
<link rel="stylesheet" href="<c:url value='/template/new_muban/css/xadmin.css'/>">   
<script src="<c:url value='/template/new_muban/lib/layui/layui.js'/>" charset="utf-8"></script> 
<script type="text/javascript" src="<c:url value='/template/new_muban/js/xadmin.js'/>"></script>

<link rel="stylesheet" href="<c:url value='/template/new_muban/css/login.css'/>">


<!-- 导出到Excal -->
<script src="<c:url value='/jsp/lead_into/js/jquery.table2excel.js'/>"></script> 



<style type="text/css">
	/*圆形头像  */
	/* #divcss5{ margin:10px auto}  */
	#divcss5 img{ border-radius:50%} 
	.x-so input.layui-input {
    	width: 150px;
	}
	/*发灰*/
	.gray { 
	    -webkit-filter: grayscale(100%);
	    -moz-filter: grayscale(100%);
	    -ms-filter: grayscale(100%);
	    -o-filter: grayscale(100%);
	    
	    filter: grayscale(100%);
		
	    filter: gray;
	}
</style>
</head>
<body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">订单管理</a>
        <a>
          <cite>订单列表</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
    </div>
    <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-body ">
					        <form class="layui-form layui-col-space5" action="<c:url value='/selectApplyUserManager.do'/>" method="get">
					          <%-- <div class="layui-inline layui-show-xs-block">
					          <input  type="text" name="order_no" value="${page.order_no}" placeholder="请输入订单编号" autocomplete="off" class="layui-input">
					          </div>
					         	 <button type="submit" class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
					         </form>
					        <form class="layui-form layui-col-space5" onsubmit="return verifyDate();" action="<c:url value='/findAllOrderPaging.do'/>" method="get">
					          <div class="layui-inline layui-show-xs-block">
					          	<input type="text" name="u_nickname" value="${page.u_nickname}" placeholder="请输入微信昵称" autocomplete="off" class="layui-input">
					          </div>
					          <div class="layui-inline layui-show-xs-block">
					          <input type="text" name="u_name" value="${page.u_name}" placeholder="请输入使用者姓名" autocomplete="off" class="layui-input">
					          </div>
					          <div class="layui-inline layui-show-xs-block">
					          <input type="text" name="u_phone" value="${page.u_phone}" placeholder="请输入使用者手机号" autocomplete="off" class="layui-input">
					          </div>
					          <div class="layui-inline layui-show-xs-block">
					          <input type="text" name="t_name" value="${page.t_name}" placeholder="请输入门票名" autocomplete="off" class="layui-input">
					           </div>

					          <div class="layui-inline layui-show-xs-block">
					          <input type="text" name="tuijian_contact" value="${page.tuijian_contact}" placeholder="请输入推荐人" autocomplete="off" class="layui-input">
					         </div>
					            <div class="layui-input-inline layui-show-xs-block">
					            <select name="order_status" id="order_status">
					              <option disabled="disabled" selected="selected">订单状态</option>
					              <option value="0">未付款</option>
					              <option value="1">待核销</option>
					              <option value="4">已核销</option>
					              <option value="-4">取消交易</option>
					            </select>
					          </div> --%>
					            <div class="layui-input-inline layui-show-xs-block">
					            <select name="page_num" id="page_num" >
					              <option disabled="disabled" selected="selected">单页查询数量</option>
					              <option value="10">10</option>
					              <option value="20">20</option>
					              <option value="50">50</option>
					              <option value="80">80</option>
					              <option value="100">100</option>
					            </select>
					          </div>
					        <%--      <div class="layui-input-inline layui-show-xs-block">
					          <input class="layui-input" value="${page.start}" placeholder="开始日" name="start" id="start" readonly>
					             </div>
					             <div class="layui-input-inline layui-show-xs-block">
					          <input class="layui-input" value="${page.end}"  placeholder="截止日" name="end" id="end" readonly>
					          </div> --%>
					          <button type="submit" class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
					        </form>
					      </div>
      	
     
         <%-- <input type="button" class="layui-btn" onclick="checkNum(${page.sumNumber},'${page.order_time}','${page.ordersale }','${page.o_order_id }','${page.o_type}','${page.dd_name}','${page.dd_user}','${page.pay_status}','${page.page_num}');" value="跳转" /> --%>
       <div class="layui-card-body layui-table-body layui-table-main">
      <table class="layui-table layui-form">
        <thead>
          <tr>
          <th>id</th>
           <th>活动名称</th>
            <th>微信头像-昵称</th>
            <th>姓名</th>
            <th>电话</th>
            <th>紧急联系人</th>
            <th>身份证号</th>
            <th>衣服尺码</th>
            <th>备注</th>
            <th>创建时间</th>
            <!-- <th>操作</th> --></tr>
        </thead>
        <tbody  id="x-img">
    
          <c:forEach items="${allApply}" var="apply" varStatus="sm">
          	<tr 
          		<%-- <c:if test="${order.order_status == -4}">style="color:#ccc"</c:if> --%>
          	>
          <td>${apply.au_id}</td>
            <td><div id="divcss5"><img width="35px" src="${apply.u_avatar}"> <font size="2">${apply.u_nickname}</font> </div> </td>
            <td>${apply.au_username}</td>
            <td>${apply.au_phone}</td>
            <td>${apply.au_e_phone}</td>
            <td>${apply.au_card}</td>
            <td>${apply.au_bz}</td>
           
            <td>${apply.addtime}</td>
        <%--     <td class="td-manage">
	
		<a title="查看核销码"  onclick="xadmin.open('查看核销码','<c:url value='/findHXCodeByOrder.do?o_id=${order.id}'/>',1280,400)" href="javascript:;">
	                <i class="layui-icon">&#xe63c;</i>
	              </a>
        
           
            </td> --%>
          </tr>
          
          </c:forEach>
     
          <tr>
        </tbody>
      </table>
      </div>
      <div style="text-align: center;">
        <span style="border: 0px solid #E2E2E2;">${page.page_num}条每页/共${page.allApplyItem}条  &nbsp;&nbsp; 第${page.number}页/共${page.sumNumber}页</span>
      </div>
      <!-- 分页查询-->
      <div class="page">
        <div>
        <!-- 页码跳转 -->
        <c:if test="${page.sumNumber > 1}">
        	<input type="text" name="number" class="layui-input inputNum" style="display: inline; width: 50px;" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();"  placeholder="页码"/>
         	<input type="button" class="layui-btn" onclick="checkNum(${page.sumNumber},'${page.start}','${page.end}','${page.u_nickname}','${page.u_name}','${page.u_phone}','${page.t_name}','${page.order_status}','${page.page_num}','${page.tuijian_contact}');" value="跳转" /> 
       	</c:if>
       		<!-- 首页/上一页 -->
       		<c:if test="${page.number > 1}">
       			<a class="prev" href="<c:url value='/selectApplyUserManager.do?number=1&page_num=${page.page_num}'/>">首页</a>
				<a class="prev" href="<c:url value='/selectApplyUserManager.do?number=${page.number-1}&page_num=${page.page_num}'/>">&lt;&lt;</a>
			</c:if>
			<!-- 计算页码列表 -->
		<c:choose>
			<%--使用c标签choose     when   otherwise   类似if else--%>
			<%-- 设置Var变量    默认在Page域中   本页面可直接使用--%>
			<c:when test="${page.sumNumber<=5}">
				<c:set var="begin" value="1"/>
				<c:set var="end" value="${page.sumNumber}"/>
			</c:when>
			
			<c:otherwise>
				<%-- 当总页数>5 通过计算得出begin和end 在第3位 --%>
				<c:set var="begin" value="${page.number-2}"/>
				<c:set var="end" value="${page.number+2}"/>
				<%-- 头溢出--%>
				<c:if test="${begin<1}">
					<c:set var="begin" value="1"/>
					<c:set var="end" value="${page.sumNumber}"/>
				</c:if>
				<!-- 为1显示5个 -->
				<c:if test="${begin==1}">
					<c:set var="begin" value="1"/>
					<c:set var="end" value="5"/>
				</c:if>
				<%-- 尾溢出--%>
				<c:if test="${end>page.sumNumber}">
					<c:set var="end" value="${page.sumNumber}"/>
					<c:set var="begin" value="${page.sumNumber-4}"/>
				</c:if>
			</c:otherwise>
		</c:choose>
		<!-- 循环遍历显示页码列表 -->
		<c:forEach var="i" begin="${begin}" end="${end}">
			<c:choose>
				<%-- 用i表示页码   如果i等于当前页码   不能点击 --%>
				<c:when test="${i eq page.number}">
					<span class="current">${i}</span>
				</c:when>
				<c:otherwise>
					<%-- 页码为超链接--%>
					<a class="num" href="<c:url value='/selectApplyUserManager.do?number=${i}&page_num=${page.page_num}'/>">${i}</a>
				</c:otherwise>
			</c:choose>
		</c:forEach>
		<!-- 计算尾部页码 -->	
		<c:if test="${page.number < page.sumNumber}">
			<a class="next" href="<c:url value='/selectApplyUserManager.do?number=${page.number+1}&page_num=${page.page_num}'/>">&gt;&gt;</a>
			
			<a class="next" href="<c:url value='/selectApplyUserManager.do?number=${page.number+1}&page_num=${page.page_num}'/>">尾页</a>
		</c:if>	
          <!-- <a class="prev" href="">&lt;&lt;</a>
          <a class="num" href="">1</a>
          <span class="current">2</span>
          <a class="num" href="">3</a>
          <a class="num" href="">489</a>
          <a class="next" href="">&gt;&gt;</a> -->
          
        </div>
      </div>
</div>
</div>
    </div>
      </div>
    <script>
    
   
   /*  
    layui.use('layer', function(){
        layer.msg('已删除!',{icon:1,time:10000},function(){
	parent.location.reload();
	let liId = $.cookie('liId');
	let liClass = $.cookie('liClass');
	console.log(liId);
	console.log(liClass);
	$('liId').attr("class","layui-nav-item layui-nav-iteme");
	console.log($(liId).attr("class"));
        	
        });  
    	
    });   */ 
    //时间
      layui.use('laydate', function(){
        var laydate = layui.laydate;
        
        //执行一个laydate实例
        laydate.render({
          elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
          elem: '#end' //指定元素
        });
      });

       /*用户-停用*/
      function member_stop(obj,id){
          layer.confirm('确认要停用吗？',function(index){

              if($(obj).attr('title')=='启用'){

                //发异步把用户状态进行更改
                $(obj).attr('title','停用')
                $(obj).find('i').html('&#xe62f;');

                $(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('已停用');
                layer.msg('已停用!',{icon: 5,time:1000});

              }else{
                $(obj).attr('title','启用')
                $(obj).find('i').html('&#xe601;');

                $(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已启用');
                layer.msg('已启用!',{icon: 5,time:1000});
              }
              
          });
      }

      /*用户-开通取消操作*/
      function member_stop_caozuo(obj,id){
              if($(obj).attr('title')=='停用'){
		          layer.confirm('确认要停用吗？',function(index){
	                //发异步把用户状态进行更改
	                $(obj).attr('title','开通')
	                $(obj).find('i').html('&#xe62f;');
	                $(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('未开通');
	                layer.msg('已停用!',{icon: 5,time:1000});
	                
	                
	                
	          	});
              }else{
            	 layer.confirm('确认要开通吗？',function(index){
	                $(obj).attr('title','停用')
	                $(obj).find('i').html('&#xe601;');
	                $(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已开通');
	                layer.msg('已开通!',{icon: 6,time:1000});
              	});
              }
      }

      /*用户-删除*/
      function member_del(obj,id){
          layer.confirm('确认要删除吗？',function(index){
              //发异步删除数据
              $(obj).parents("tr").remove();
              layer.msg('已删除!',{icon:1,time:1000});
          });
      }



      function delAll (argument) {

        var data = tableCheck.getData();
  
        layer.confirm('确认要删除吗？'+data,function(index){
        
            //捉到所有被选中的，发异步进行删除
            layer.msg('删除成功', {icon: 1});
            $(".layui-form-checked").not('.header').parents('tr').remove();
        });
      }
    </script>

     
     <!-- 1 绿√  2 红X  3 黄?  4  灰锁  5  红哭脸  6 绿笑脸 7 黄!  --> 
    <!-- //页面跳转 -->
<script type="text/javascript">
	function checkNum(sumNumber,start,end,u_nickname,u_name,u_phone,t_name,order_status,page_num,tuijian_contact){
		var num = $(".inputNum").val();
		/* //prompt层		//prompt层
		layer.prompt({title: '输入任何口令，并确认', formType: 1}, function(pass, index){
			  layer.close(index);
			  layer.prompt({title: '随便写点啥，并确认', formType: 2}, function(text, index){
			    layer.close(index);
			    layer.msg('演示完毕！您的口令：'+ pass +'<br>您最后写下了：'+text);
			  });
			});
		return false; */
		
		//alert(sumNumber+"/"+num+"/"+s_name+"/"+s_contact+"/"+s_phone+"/"+openid+"/"+pay_status+"/"+start+"/"+end+"/"+page_num );
		if(!isNaN(num)){      
			//alert("是数字类型!");
			if (num>sumNumber) {
				//alert("超出查询范围");
				layer.alert('超出查询范围!!',{icon:2,time:2000});
				return false;
			} else if (num<1) {
				//alert("请输入正确的页码");
				layer.alert('请输入正确的页码!',{icon:2,time:2000});
				return false;
			} else {
		 		window.location.href = "<c:url value='/findAllOrderPaging.do?u_name="+u_name+"&t_name="+t_name+"&u_phone="+u_phone+"&number="+num+"&u_nickname="+u_nickname+"&order_status="+order_status+"&start="+start+"&end="+end+"&page_num="+page_num+"&tuijian_contact="+tuijian_contact+"'/>";
			}
		}else{      
			//alert("不是数字类型!");
			layer.alert('不是数字类型!',{icon:2,time:2000});
			return false;
		}
	}
/*
 * 验证 查询时间大小 
 */	
 function verifyDate() {
	var start = $("#start").val();
	var end = $("#end").val();
	//alert(start > end);
	if(start > end){
		//alert("开始日期不能大于结束日期!");
		layer.alert('开始日期不能大于结束日期!',{icon:2,time:3000});
		return false;		
	}
}

 /*
  * 显示隐藏状态编辑
  */	
  
  var aid;
  
  function editStatus(id,aid) {
	aid = aid;
	 $("#edit_status_show"+id).hide();
	  $("#edit_status_hidden"+id).show();
		 //$("#"+aid).parents('tr:first').css({backgroundColor:'#d1eac8'});
	// 按钮的父节点的父节点是tr。  
      /* var tr = obj.parentNode.parentNode;  
      alert(tr.rowIndex); 
      tr.setAttribute('align','center'); 
      tr.setAttribute('bgcolor','#black'); */
 }
 /**
 修改订单状态
 */
 layui.use(['form','layer'], function(){
     $ = layui.jquery;
   var form = layui.form
   ,layer = layui.layer;

   form.on('select(search_type)', function(data){
	   
	   //修改确认
	   layer.confirm('确认要修改吗？',function(index){
	   
	   
	                
	   
		console.log(data.elem); //得到select原始DOM对象
		 console.log(data.value); //得到被选中的值
		 console.log(data.othis); //得到美化后的DOM对象
		 //要更改的状态
		 var id_status = data.value;
		 //分割id 和 status
		 var flag =id_status.indexOf("_");
		var id= id_status.substring(0,flag);
		var order_status= id_status.substring(flag+1,id_status.length);
		 console.log(id +"  :  " +order_status);
		//发异步，把数据提交给php
         $.ajax({
             type: "POST",
             async : false, // 注意此处需要yi步  
             url:  "<c:url value='/updateOrderStatus.do'/>",
             data: {"id":id,"order_status":order_status,},
             success: function(data){
                 if (data == 0) {
                	 aa = 0;
                 } else  {
                	 aa = 1;
		           } 
            }
	        });   
        
         if(aa == 0){
             //layer.msg('修改失败,未知错误!',{icon: 2,time:3000});   
             layer.msg("修改失败,未知错误!", {icon: 2,time:3000},function () {
                 // 获得frame索引
                 var index = parent.layer.getFrameIndex(window.name);
                 //alert(index);
                location.reload();
             });
         }else if(aa == 1){
        	  layer.msg("修改成功", {icon: 6,time:500},function () {
                  // 获得frame索引
                  var index = parent.layer.getFrameIndex(window.name);
                  //alert(index);
                 location.reload();
        
              });
         }
       	//禁止页面自动跳转
          return false;
	   });
	});
 });
 
 layui.use('layer', function(){
     $ = layui.jquery;//jquery
   layer = layui.layer;//弹出层


     layer.ready(function(){ //为了layer.ext.js加载完毕再执行
       layer.photos({
         photos: '#x-img'
       });
     });
  
 });

</script>      
      
  </body>
</html>